hackerrank ruby strings methods II problem solution